/*******************************************************************************
* File Name          : debug_log.c 
* Author             : Aaron Zhuang
* Description        : 

*******************************************************************************/

/* Includes-------------------------------------------------------------------*/
#include "segger_rtt_debug.h"
#include "SEGGER_RTT.h"
#include "stdint.h"

#include "Foc.h"
#include "Svpwm.h"

//为调试方便，仅在此调用一个全局，不能对其赋值。

/* Private define ------------------------------------------------------------*/

/* Private typedef -----------------------------------------------------------*/

/* Private macro -------------------------------------------------------------*/

/* Private function prototypes -----------------------------------------------*/

/* Private variables -----------------------------------------------------------*/
extern Foc foc;
extern Svpwm svpwm;

volatile uint8_t   rtt_buf1[6*2000];		//RTT
#pragma   pack(push, 1)
struct
{
   float      var1;  
   float      var2;
   float      var3;
   
   float      var4;  
   float      var5;  
   float      var6; 

//   s16      var7;
//   s16      var8;
//   s16 	    var9;	
//   s16 	    var10;
//   s16 	    var11;
//   s16 	    var12;
	
} varbuf;
#pragma pack(pop)

/* Log Initial RTT */
void Init_RTT(void)
{
      /*______________________JSCOPE_INIT____________________________*/
	// SEGGER_RTT_ConfigUpBuffer (1, "JScope_i2i2i2i2i2i2i2i2i2i2i2i2", rtt_buf1, sizeof(rtt_buf1), SEGGER_RTT_MODE_NO_BLOCK_SKIP);
	   SEGGER_RTT_ConfigUpBuffer (1, "JScope_f4f4f4f4f4f4", rtt_buf1, sizeof(rtt_buf1), SEGGER_RTT_MODE_NO_BLOCK_SKIP);
    // SEGGER_RTT_ConfigUpBuffer (1, "JScope_i2i2i2u2u2i2", rtt_buf1, sizeof(rtt_buf1), SEGGER_RTT_MODE_NO_BLOCK_SKIP);
    // SEGGER_RTT_ConfigUpBuffer (1, "JScope_i2i2i2", rtt_buf1, sizeof(rtt_buf1), SEGGER_RTT_MODE_NO_BLOCK_SKIP);
	// SEGGER_RTT_ConfigUpBuffer (1, "JScope_i2i2i2i2", rtt_buf1, sizeof(rtt_buf1), SEGGER_RTT_MODE_NO_BLOCK_SKIP);
	//   SEGGER_RTT_ConfigUpBuffer (1, "JScope_i2i2i2i2i2", rtt_buf1, sizeof(rtt_buf1), SEGGER_RTT_MODE_NO_BLOCK_SKIP);
	
	/*      i2 = s16 ,  i4 = s32 ,   u2 = u16 ,  u4 = u32  f4=float  f8=double     */    
}                                   

void Log_Data(void)  //  8 个  FOC_mode
{

//    varbuf.var1 = ialast0;
//    varbuf.var2 = iacur0;	 
//    varbuf.var3 = FOC_Drag.hAngle;


//   varbuf.var1 = ialast0;//FOC_Drag.IA;   
//   varbuf.var2 = iacur0;//FOC_Drag.IB;   
//   varbuf.var3 = iblast0;//FOC_Drag.Iq;
//   varbuf.var4 = ibcur0;//FOC_Drag.Id;
//   varbuf.var5 = SumAngle;
//   varbuf.var6 = FOC_Drag.hAngle;


//varbuf.var1 = FOC_Drag.hAngle;   
//varbuf.var2 = FOC_Drag.Valpha;	 
//varbuf.var3 = FOC_Drag.Vbeta;
//varbuf.var4 = FOC_Drag.Ta;
//varbuf.var5 = FOC_Drag.Tb;
//varbuf.var6 = FOC_Drag.Tc;

//   varbuf.var1 = FOC_Drag.IA;   
//   varbuf.var2 = FOC_Drag.IB;   
//   varbuf.var3 = FOC_Drag.Iq;
//   varbuf.var4 = FOC_Drag.Id;
//   varbuf.var5 = FOC_Drag.Ibeta;
//   varbuf.var6 = FOC_Drag.hAngle;

//   varbuf.var1 = FOC_mode.RevParkAngle;   
//   varbuf.var2 = FOC_mode.IA;   
//   varbuf.var3 = FOC_mode.IB;
//   varbuf.var4 = FOC_mode.Ialpha;
//   varbuf.var5 = FOC_mode.Ibeta;
//   varbuf.var6 = FOC_mode.Iq;

//	varbuf.var1 = FOC_mode.RevParkAngle;   
//	varbuf.var2 = FOC_mode.Valpha;	 
//	varbuf.var3 = FOC_mode.Vbeta;
//	varbuf.var4 = FOC_mode.Ta;
//	varbuf.var5 = FOC_mode.Tb;
// 	varbuf.var6 = FOC_mode.Tc;

   varbuf.var1 = foc.ualpha*100;//
   varbuf.var2 = foc.ubeta*100;//	
   varbuf.var3 = foc.theta*100;//   
   varbuf.var4 = svpwm.out_Tcm1*100;//
   varbuf.var5 = svpwm.out_Tcm2*100;//
   varbuf.var6 = svpwm.out_Tcm3*100;//
   
//   varbuf.var7 = FOC_mode.tmp7;//
//   varbuf.var8 = FOC_mode.tmp8;//	
//   varbuf.var9 = FOC_mode.tmp9;//
//  varbuf.var10 = FOC_mode.tmp10;//
//  varbuf.var11 = FOC_mode.tmp11;//
//  varbuf.var12 = FOC_mode.tmp12;//

//   varbuf.var1 = AngleSpdNow55.Input_Present;  
//   varbuf.var2 = AngleSpdNow55.Sum1;	
//   varbuf.var3 = AngleSpdNow55.SumError;//
//   varbuf.var4 = AngleSpdNow55.Temp1;//
//   varbuf.var5 = AngleSpdNow55.spd32n;
//   varbuf.var6 = AngleSpdNow55.Angle_Elec;
   
   SEGGER_RTT_Write (1, &varbuf, sizeof(varbuf));  
}

  


/****END OF FILE****/

